package com.xbts.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xbts.common.annotation.Log;
import com.xbts.common.core.controller.BaseController;
import com.xbts.common.core.domain.AjaxResult;
import com.xbts.common.enums.BusinessType;
import com.xbts.system.domain.CnVirtuallyUserHwAccount;
import com.xbts.system.service.ICnVirtuallyUserHwAccountService;
import com.xbts.common.utils.poi.ExcelUtil;
import com.xbts.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

/**
 * 用户和华为云账号绑定（虚拟）Controller
 * @author xbts
 * @date 2023-11-30
 */
@Api("用户和华为云账号绑定（虚拟）")
@RestController
@RequestMapping("/system/virtually/account")
public class CnVirtuallyUserHwAccountController extends BaseController {

    @Autowired
    private ICnVirtuallyUserHwAccountService cnVirtuallyUserHwAccountService;

    /**
     * 查询用户和华为云账号绑定（虚拟）列表
     */
    @ApiOperation("查询用户和华为云账号绑定（虚拟）列表")
    @PreAuthorize("@ss.hasPermi('system:virtuallyAccount:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody CnVirtuallyUserHwAccount cnVirtuallyUserHwAccount) {
        startPage(cnVirtuallyUserHwAccount);
        List<CnVirtuallyUserHwAccount> list = cnVirtuallyUserHwAccountService.selectCnVirtuallyUserHwAccountList(cnVirtuallyUserHwAccount);
        return getDataTable(list);
    }

    /**
     * 导出用户和华为云账号绑定（虚拟）列表
     */
    @ApiOperation("导出用户和华为云账号绑定（虚拟）列表")
    @PreAuthorize("@ss.hasPermi('system:virtuallyAccount:export')")
    @Log(title = "用户和华为云账号绑定（虚拟）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response,@RequestBody CnVirtuallyUserHwAccount cnVirtuallyUserHwAccount) {
        List<CnVirtuallyUserHwAccount> list = cnVirtuallyUserHwAccountService.selectCnVirtuallyUserHwAccountList(cnVirtuallyUserHwAccount);
        ExcelUtil<CnVirtuallyUserHwAccount> util = new ExcelUtil<CnVirtuallyUserHwAccount>(CnVirtuallyUserHwAccount.class);
        util.exportExcel(response, list, "用户和华为云账号绑定（虚拟）数据");
    }

    /**
     * 获取用户和华为云账号绑定（虚拟）详细信息
     */
    @ApiOperation("获取用户和华为云账号绑定（虚拟）详细信息")
    @ApiImplicitParam(name = "userId", value = "用户和华为云账号绑定（虚拟）ID", required = true, dataType = "String", paramType = "path", dataTypeClass=String.class)
    @PreAuthorize("@ss.hasPermi('system:virtuallyAccount:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") String userId) {
        return success(cnVirtuallyUserHwAccountService.selectCnVirtuallyUserHwAccountByUserId(userId));
    }

    /**
     * 新增用户和华为云账号绑定（虚拟）
     */
    @ApiOperation("新增用户和华为云账号绑定（虚拟）")
    @PreAuthorize("@ss.hasPermi('system:virtuallyAccount:add')")
    @Log(title = "用户和华为云账号绑定（虚拟）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody CnVirtuallyUserHwAccount cnVirtuallyUserHwAccount) {
        return toAjax(cnVirtuallyUserHwAccountService.insertCnVirtuallyUserHwAccount(cnVirtuallyUserHwAccount));
    }

    /**
     * 修改用户和华为云账号绑定（虚拟）
     */
    @ApiOperation("修改用户和华为云账号绑定（虚拟）")
    @PreAuthorize("@ss.hasPermi('system:virtuallyAccount:edit')")
    @Log(title = "用户和华为云账号绑定（虚拟）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody CnVirtuallyUserHwAccount cnVirtuallyUserHwAccount) {
        return toAjax(cnVirtuallyUserHwAccountService.updateCnVirtuallyUserHwAccount(cnVirtuallyUserHwAccount));
    }

    /**
     * 删除用户和华为云账号绑定（虚拟）
     */
    @ApiOperation("删除用户和华为云账号绑定（虚拟）")
    @ApiImplicitParam(name = "userIds", value = "用户和华为云账号绑定（虚拟）ID集合", required = true, dataType = "String", paramType = "path", dataTypeClass=String.class)
    @PreAuthorize("@ss.hasPermi('system:virtuallyAccount:remove')")
    @Log(title = "用户和华为云账号绑定（虚拟）", businessType = BusinessType.DELETE)
	@PostMapping("/batchDelete")
    public AjaxResult batchDelete(@RequestBody List<String> userIds) {
        return toAjax(cnVirtuallyUserHwAccountService.deleteCnVirtuallyUserHwAccountByUserIds(userIds));
    }
}
